﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace QLTV.Forms.KeHoach
{
    public partial class frmKeHoachPopup : DevExpress.XtraEditors.XtraForm
    {
        public frmKeHoachPopup()
        {
            InitializeComponent();  
        }
        public int planid { get; set; }
        public bool isNew { get; set; }

        private void frmKeHoachPopup_Load(object sender, EventArgs e)
        {
            if (isNew)
            {
                tblKeHoachBindingSource.AddNew();
                radioGroup1.SelectedIndex = 0;
                datePlanCreated.EditValue = DateTime.Now.Date;
            }
            else
            {

                this.tblKeHoachTableAdapter.FillByID(this.dsLongPlan.tblKeHoach, planid);
                lbldate.Text = "Ngày chỉnh sửa";
                datePlanCreated.EditValue = DateTime.Now.Date;
                datePlanCreated.DataBindings.RemoveAt(0);
                this.datePlanCreated.DataBindings.Add(new System.Windows.Forms.Binding("EditValue", this.tblKeHoachBindingSource, "Ngày chỉnh sửa", true));
            }
            txtNguoiLap.EditValue = Program.EmployeeName;
        }

        private void cmdCreate_Click(object sender, EventArgs e)
        {
            if ((bool)radioGroup1.Properties.Items[radioGroup1.SelectedIndex].Value == true)
            { 
                //Long plan
                this.Close();
                frmLongPlanVessel f = new frmLongPlanVessel();
                f.Show();
           

            }
        }
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void cmdSave_Click(object sender, EventArgs e)
        {
            tblKeHoachBindingSource.EndEdit();
            tblKeHoachTableAdapter.Update(dsLongPlan.tblKeHoach);
            this.Close();
        }
    }
}